import { Button, Modal ,Input} from 'antd';
import React, { useState } from 'react';
import '../../../assets/css/Car/Carxg.css';
import axios from '../../../utils/axios'

const { TextArea } = Input;

const Carxg = (props) => {
  const [visible, setVisible] = useState(false);

  const [value, setValue] = useState(1);

  const getxgvalue = (e) => {
    console.log(e.target.name + e.target.value);
    // console.log(myxgvaluearr.car_user);
    myxgvaluearr[e.target.name] = e.target.value;
  }
  const huoqushuj = () => {
    setVisible(true);

  }
  const Newvalue = () => {
    setVisible(false)
    axios({
      url: "/car/carPage/updateCar",
      method: "get",
      params: {
        car_location: myxgvaluearr.car_location,
        car_Status: myxgvaluearr.car_Status,
        car_model: myxgvaluearr.car_model,
        car_color: myxgvaluearr.car_color,
        car_id: myxgvaluearr.car_id,
      }
    }).then((res) => {
      console.log(res);
    }).then((err) => {
      console.log(err);
    })
  }
  const myxgvaluearr = {
    car_location: '',
    car_Status: '',
    car_model: '',
    car_color: '',
    car_id: '',
  }
  return (
    <>
      <Button type="primary" onClick={huoqushuj} className='xgbtn'>
        修改
      </Button>
      <Modal
        title="修改车辆信息"
        centered
        visible={visible}
        onOk={Newvalue}
        okText={'确定'}
        cancelText={'取消'}
        onCancel={() => setVisible(false)}
        width={500}

      >

        <table>
          <div className='xgcbox'>
            <span className='xh'>* </span>
            <span>所在位置：</span>
            <select onChange={getxgvalue} name='car_location'>
              <option name="0">请选择</option>
              <option name="总经办">总经办</option>
              <option name="财务部">财务部</option>
              <option name="业务一部">业务一部</option>
              <option name="业务二部">业务二部</option>
              <option name="渠道招商部">渠道招商部</option>
              <option name="营销部">营销部</option>
              <option name="采购部">采购部</option>
              <option name="客服部">客服部</option>
            </select>
          </div>

          <div className='ibox'>
            <span className='xh'>* </span><span>车辆状态：</span>
            <select onChange={getxgvalue} name='car_Status'>
              <option name='0'>请选择</option>
              <option name='使用中'>使用中</option>
              <option name='闲置'>闲置</option>
            </select>
          </div>

          <div className='ibox'>
            <span className='xh'>* </span><span>车辆型号：</span>
            <input type={"text"} onChange={getxgvalue} name='car_model'></input>
          </div>
          <div className='ibox'>
            <span className='xh'>* </span><span>车辆颜色：</span>
            <input type={"text"} onChange={getxgvalue} name='car_color'></input>
          </div>

          <div className='ibox'>
            <span className='xh'>* </span><span>车辆牌照：</span>
            <input type={"text"} onChange={getxgvalue} name='car_id'></input>
          </div>
        </table>
      </Modal>
    </>
  );
};

export default Carxg;
